

var str = location.search;
var bool;
str = str.slice(1).split('&');
var json = {};
for(var i = 0; i < str.length; i++) {
    var a = str[i].split('=');
    json[a[0]] = a[1];
}
console.log(json);

$("#srueAlert").click(function  () {

  	$.ajax({
  		type:"get",
  		url:"http://192.168.59.3:8082/console/projectcapital/addProjectTeamCapital/?due="+$(".editAlert>div>input").eq(1).val()+"&transactionTime="+$(".editAlert>div>input").eq(2).val()+"teamId="+json.teamId,
  		dataType:'json',

  		contentType:"application/json",
  		success:function(data){
  			console.log(data);
  			parent.layer.closeAll();

  		},
  		error: function  (err){
  			console.log(err);
  		}

  	});

  });



















$(function(){
	/*解析href*/
    var str = location.search;
    str = str.slice(1).split('&');
    var json = {};
    for (var i = 0; i < str.length; i++) {
        var a = str[i].split('=');
        json[a[0]] = a[1];
    }
    //console.log(json);

	/*工人出勤明细获取*/
    var
        oDataTime           = $('#dataTime'),
        oOrgWorkTimeStart   = $('#orgWorkTimeStart'),//进场时间/工地
        oOrgWorkTimeEnd     = $('#orgWorkTimeEnd'),//出场时间/工地
        oWorkTime           = $('#workTime');//工数/工地


    var
        oDataTimeVal = '',
        oOrgWorkTimeStartVal = '',
        oOrgWorkTimeEndVal = '',
        oWorkTimeVal = '';

    if(json.edit == 1){
        $('#dataTime').val(json.teamId);
        oOrgWorkTimeStart.val(json.chgWorkTimeStart);
        oOrgWorkTimeEnd.val(json.chgWorkTimeEnd);
        oWorkTime.val(json.workTime);

    }

    $('#saveBtn').click(function(){
        oDataTimeVal            =   oDataTime.val(),
            oOrgWorkTimeStartVal    =   oOrgWorkTimeStart.val(),
            oOrgWorkTimeEndVal      =   oOrgWorkTimeEnd.val(),
            oWorkTimeVal            =   oWorkTime.val();


        if(json.edit == 1){
            oData = [{



                "projectCode": json.projectCode,
                "teamId": json.teamId

            }];
                 $.ajax({
                 	type:"put",
					url:"http://192.168.59.3:8082/console/projectcapital/updateProjectTeamCapital/1/"+json.teamId+"/"+json.due,
                    contentType:"application/json",
					 success:function (data) {
						 console.log(data);
                         parent.layer.closeAll();
                     },
					 error:function (err) {
						 console.log(err);
                     }
				 })


        }else{

            oData = [{
                "dataTime"          : oDataTimeVal,
                "orgWorkTimeStart"  : oOrgWorkTimeStartVal,
                "orgWorkTimeEnd"    : oOrgWorkTimeEndVal,
                "workTime"          : oWorkTimeVal,
				"projectCode"       : json.projectCode,
                "teamId"            : json.teamId,
                "userCode"          : json.userCode
            }];


            $.ajax({
                type:"get",
                url:"http://192.168.59.3:8082/console/projectcapital/addProjectTeamCapital/?due="+$('#dataTime').val()+"&transactionTime="+$('#orgWorkTimeStart').val()+"teamId="+json.teamId,
                dataType:'json',
                contentType:"application/json",
                success:function(data){
                    console.log(data);
                    parent.layer.closeAll();

                },
                error: function  (err){
                    console.log(err);
                }

            });

        }


    });

});

function responseHandler(res) {
    var needData = {
        rows: res.data.list,
        total: res.data.total
    };
    return needData;
}
